#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include <QtGui/QSplashScreen>
#include <QToolButton>
#include <QComboBox>
#include <QDebug>
#include <QFileDialog>
#include <QSettings>
#include "listeclient.h"
#include "importcsv.h"
#include "listeclienttableview.h"
#include "listeclientmodel.h"
#include "formclient.h"
#include "formconfiguration.h"
#include "formmainlist.h"
#include "databasemanager.h"
#include "listeusers.h"
#include "objtosql.h"
#include "laddatabasemanager.h"


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QSplashScreen *sp, QWidget *parent = 0);
    ~MainWindow();

private slots:
    void clicMenu(QAction * action);
    void ShowMainList();
    void ShowFormClient();
    void ShowFormConfiguration();
    void ImportCSVs();

    void AddValue(objToSQL &value);
    void ImportListeClient(ListeClient liste);
    void RemoveFromDb(QStringList sqlWhere , QString NomTable, bool containsListe = false);

signals :
    void EnvoiClient(Client *client);

    void Message(QString message, int alignment = Qt::AlignBottom);

    void FiltreTypeClient(QString type);
    void ChoixTypeClient(QString type);
    void ChoixDepartement(QString Departement);

private:
    Ui::MainWindow *ui;
    QSettings *m_settings;
    QString m_version;
    QString m_dataFolder;
    QStringList m_listeTypeSono;
    QStringList m_listeTypeClient;
    ListeClient m_listeClient;
    ListeUsers m_listeUsers;
    ListeTypePrestation m_listeTypePrestation;
    databaseManager db;
    ladDatabaseManager ladDb;
    ListeContact m_listeContact;
    ListeDateContact m_listeDateContact;

    void CreationGUI();
    void AssociationAction();
    void ConnectionSignauxSlots();

    //init
    void ChargementSettings();
    void ChargementListe();
    void InitialisationSQL();

    //acces data
    QStringList OuvertureFichier(QString filename);
    bool SauvegardeVersFichier(QString filename, QStringList sdata);
    void SaveSettings();
    void SaveToDb();

    // GUI
    void CreationToolBar(QString title, QStringList itemMenu);
    QList<QMenu*> m_listeMenu;
    QLabel *labelFiltre;
    QLineEdit *lineEditFiltre;

    QComboBox *comboBoxChoixTypeClient;
    QComboBox *comboBoxChoixDepartement;

    QAction *actionImportCSV;
    QAction *actionNouveauClient;
    QAction *actionQuitter;

    FormMainList *m_formMainList;
    FormClient *m_formClient;
    FormConfiguration *m_formConfiguration;
    ImportCSV *m_importCSV;

    // Navigation

    QAction *actionShowMainList;
    QAction *actionShowFormClient;
    QAction *actionShowFormConfiguration;

};

#endif // MAINWINDOW_H
